package utils


import (
	"crypto/md5"
	"fmt"
	"math/rand"
	"time"
)

func CreateRandom() string {
	return fmt.Sprintf("%10v", rand.New(rand.NewSource(time.Now().UnixNano())).Int63n(10000000000))
}


// Med5Encryption Md5加密
func Med5Encryption(appId string, q string, appKey string) string {
	initStr := appId + q + CreateRandom() + appKey
	sum := md5.Sum([]byte(initStr))
	return fmt.Sprintf("%x", sum)
}


// Med5EncryptionWithSalt Md5加密
func Med5EncryptionWithSalt(appId string, q string, salt string, appKey string) string {
	initStr := appId + q + salt + appKey
	sum := md5.Sum([]byte(initStr))
	return fmt.Sprintf("%x", sum)
}